package com.baizhi.cmfzdemo.controller;

import com.baizhi.cmfzdemo.entity.CmfzAdmin;
import com.baizhi.cmfzdemo.service.CmfzAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * Created by 54433 on 2019/4/3.
 */
@Controller
@RequestMapping("/admin")
public class CmfzAdminController {
    @Autowired
    private CmfzAdminService adminService;
    @RequestMapping("/login")
    public String login(CmfzAdmin cmfzAdmin, HttpSession session){
        CmfzAdmin cmfzAdmin1 = adminService.login(cmfzAdmin);
        if(cmfzAdmin1 !=null){
            session.setAttribute("admin", cmfzAdmin1);
            return "main/main";
        }else {
            return "login";
        }
    }
}
